package com.example.bbs.controller;

import com.example.bbs.domain.entity.Notice;
import com.example.bbs.domain.model.NoticeResponse;
import com.example.bbs.domain.model.Page;
import com.example.bbs.service.impl.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * 通知接口
 */
@Controller
public class NoticeController {

    @Autowired
    private NoticeService noticeService;


    /**
     * 评论相关通知
     *
     * @param page
     * @param model
     * @return
     */
    @GetMapping("/notice/comment")
    public String commentNotice(Page page, Model model) {

        NoticeResponse noticeResponse = noticeService.getCommentNotices(page.getPage(), page.getLimit());

        page.setPath("/notice/comment");
        page.setTotalSize(noticeResponse.getTotalSize());

        List<Notice> commentNotices = noticeResponse.getNoticeList();

        model.addAttribute("commentNotices", commentNotices);
        return "notice";
    }

}
